﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>8.3.Attribute服务端缓存</title>
    <script type="text/javascript" src="../Content/highlighter/scripts/shCore.js"></script>
    <script type="text/javascript" src="../Content/highlighter/scripts/shBrushJScript.js"></script>
    <script type="text/javascript" src="../Content/highlighter/scripts/shBrushCSharp.js"></script>
    <script type="text/javascript" src="../Content/highlighter/scripts/shBrushXml.js"></script>
    <link type="text/css" rel="stylesheet" href="../Content/highlighter/styles/shCoreDefault.css" />
    <script type="text/javascript">SyntaxHighlighter.all();</script>
</head>
<body>
    <h3>Attribute服务端缓存</h3>
    <p>
        使用缓存之前，必须先引入NFinal.Advanced;命名空间
    </p>
	<style>
	table
	{
		border-top:1px solid black;
		border-left:1px solid black;
	}
	td
	{
		border-right:1px solid black;
		border-bottom:1px solid black;
	}
	</style>
	<p>
		服务端缓存分为四种情况。
		<table cellspacing="0">
			<tr>
				<td>Server对应的枚举值</td>
				<td>说明</td>
			</tr>
			
			<tr>
				<td>NoCache</td>
				<td>表示不缓存，动态页面默认值</td>
			</tr>
			<tr>
				<td>FileDependency</td>
				<td>指访问的文件如果不修改或未超时就一直缓存。</td>
			</tr>
			<tr>
				<td>AbsoluteExpiration</td>
				<td>绝对超时，指过了指定缓存时间后，缓存自动失效。</td>
			</tr>
			
			<tr>
				<td>SlidingExpiration</td>
				<td>滑动超时，指最后一次访问时间与上一次访问时间的时间间隔如果大于某个时间则缓存失效。</td>
			</tr>
		</table>
	</p>
	<pre class="brush: csharp;">
        //urlPrefix="/App";
        namespace WebSite.App.Controllers
        {
            public class IndexController
            {
				//Server.NoCache表示服务端使用滑动超时，时间间隔为100分钟。
				//Browser.NoStore表示浏览器不缓存。
				[Cache(Server.SlidingExpiration,Browser.NoStore,6000)]
                public void Index()
                {
                    Write("Hello!");
                }
            }
        }
    </pre>
</body>
</html>
